package com.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.dto.Business;
import com.dto.CreditDto;
import com.dto.EmpInfo;
import com.dto.UserInfo;
import com.service.BusinessService;
import com.util.CreditUtile;
import com.util.PageUtilLei;

//贷款申请表
@RestController
@RequestMapping("/Business")
public class BusinessAction {
	@Autowired
	private BusinessService BuinessService;
	
	//	公司 复审查询01   《ly》
	@RequestMapping("gsfs.do")
	public ModelAndView fushenApply(PageUtilLei pageLei){
		ModelAndView mv = new ModelAndView();
		Integer totalNum=BuinessService.queryAllBusiness(pageLei);//查总条数
		pageLei = new PageUtilLei(pageLei.getPageNum(),pageLei.getPageSize(),totalNum,pageLei);
		List<Business> GSList =BuinessService.fuShenGS(pageLei); //调用复审方法
		mv.addObject("pageUtil", pageLei);
		mv.addObject("GSList", GSList);//将结果集放入request中
		mv.setViewName("forward:/fuShen03.jsp");
		return  mv;
	}
	
//	//复审调查征信的方法
//	@RequestMapping("zxjk.do")
//	public List<CreditDto> zxjk(String realname,String idcard) throws Exception {
//	//	Map<String,Object> map = new HashMap<String,Object>();
//		List<CreditDto> zxList = CreditUtile.Get(realname, idcard);
//			/*	map.put("zxList", zxList);*/
//		return zxList;
//	}
	
	//通过复审审核 《ly》
	public ModelAndView okBusiness(String pay_num) {
		ModelAndView mv = new ModelAndView();
		int x =	BuinessService.OKBusinessFs(pay_num);
		if(x > 0) {
			mv.setViewName("forward:gsfs.do");
		}
		return mv;
	}
	
	
		//未通过复审审核 《ly》
		@RequestMapping("bohui.do")
		public ModelAndView noBusiness(HttpSession sess,Business bus) {
			ModelAndView mv = new ModelAndView();
			Map<String,Object> sur = new HashMap<String,Object>();
			UserInfo userInfo = (UserInfo) sess.getAttribute("userInfo");//获取用户session中的值
			EmpInfo empInfo = (EmpInfo) sess.getAttribute("emp");//获取员工session中的值
			sur.put("e_id", empInfo.getE_id());
			sur.put("u_id", userInfo.getU_id());
			int x =	BuinessService.noBusinessFs(bus);
			if(x > 0) {
				mv.setViewName("forward:gsfs.do");
			}
			return mv;
		}
	
}
